Object.defineProperty(exports, "__esModule", { value: !0 }),
  (exports.default = void 0);
var e = require("../../@babel/runtime/helpers/classCallCheck"),
  t = require("../../@babel/runtime/helpers/createClass"),
  s = (function () {
    function s() {
      e(this, s), (this.listeners = {});
    }
    return (
      t(s, [
        {
          key: "on",
          value: function (e, t) {
            "function" == typeof t &&
              (this.listeners[e] || (this.listeners[e] = []),
              this.listeners[e].indexOf(t) < 0 && this.listeners[e].push(t));
          },
        },
        {
          key: "emit",
          value: function (e) {
            var t = this.listeners[e],
              s = Array.prototype.slice.call(arguments);
            if ((s.shift(), t))
              for (var i = 0, r = t.length; i < r; i++) t[i].apply(this, s);
          },
        },
        {
          key: "hasListener",
          value: function (e) {
            var t = this.listeners[e];
            return t && t.length > 0;
          },
        },
        {
          key: "off",
          value: function (e, t) {
            this.listeners[e] &&
              (void 0 === t
                ? delete this.listeners[e]
                : (this.listeners[e] = this.listeners[e].filter(function (e) {
                    return t !== e;
                  })));
          },
        },
        {
          key: "dispose",
          value: function () {
            for (var e in this.listeners) this.off(e);
          },
        },
      ]),
      s
    );
  })();
exports.default = s;
